package pancake.function;

import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

public class MyListFan extends Activity
{
    private static final String TAG="DemoActivity";
    private Context context;
    private ListView listview;
    private ArrayList<MyListFanItemView.Data> data;
    private MyListAdapter myadapter;
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listfan);
        this.context = this;
        ShowCustomList();
        RegEvents();
       
        
        
    }
    private void RegEvents()
    {
    	 listview.setOnItemClickListener(new OnItemClickListener(){
 			@Override
 			public void onItemClick(AdapterView<?> arg0, View v, int position,long id) 
 			{
 				// TODO Auto-generated method stub
 				/*
 				//MyListItemView cusitem = (MyListItemView)listview.getItemAtPosition(position);
 				TextView myview =(TextView)v.findViewById(R.id.txtName);
 				//listview.getItemAtPosition(position).getClass();
 				setTitle(myview.getText());	
 				*/			
 			}
         });
    	 
    	 listview.setOnItemLongClickListener(new OnItemLongClickListener(){
			@Override
			public boolean onItemLongClick(AdapterView<?> arg0, View v,
					int position, long id) {

				return true;
			}
    		 
    	 });
    }
	private void ShowCustomList()
	{
	   	this.listview = (ListView)findViewById(R.id.myListFan);
	    this.data = new ArrayList<MyListFanItemView.Data>();
	    this.InitList();
	    this.myadapter = new MyListAdapter(context,this.data);
	    this.listview.setAdapter(this.myadapter);
	}
	private void InitList()
	{
	   	MyListFanItemView.Data d;
	   	for(int i=0;i<10;i++)
	   	{
	   		d = new MyListFanItemView.Data();
	   		d.name = "Name " + Integer.toString(i);
	   		d.message = "Message Test"+ Integer.toString(i);
	   		d.date = "Date is " + Integer.toString(i);
	   		d.via = "Via " + Integer.toString(i);
	   		d.imgURLId = R.drawable.android;
	   		this.data.add(d);   		
		 }
	}
}
